/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie;

/**
 *
 * @author admin
 */
import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

public class connection {
    


//    String jdbcUrl = "jdbc:oracle:thin:@172.23.9.185:1521:orcl";
//    String userid = "MHS105314099";
//    String password = "MHS105314099";
//    String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
//    String userid = "hr";
//    String password = "afterglow";
//    String jdbcUrl = "jdbc:oracle:thin:@172.23.9.185:1521:orcl";
//    String userid = "MHS105314099";
//    String password = "MHS105314099";
    String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
    private static String jdbUrl = "jdbc:oracle:thin:@localhost:1521:xe";
    private static String useri = "hr";
        private static  String passwor = "afterglow";
    String userid = "hr";
    String password = "afterglow";


    Connection conn;
    private static Connection con;
    Statement stmt;
    ResultSet rset;
    String query;
    String sqlString;

    public connection() {
    }

    public Connection getDBConnection() {
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi berhasil");

        } catch (SQLException ex) {
            System.out.println("Masih belum koneksi");
        }
        return conn;
    }

    public static Connection getDatabaseConnection() {
        try {
            try {
                Class.forName("oracle.jdbc.driver.OracleDriver");
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
            con = DriverManager.getConnection(jdbUrl, useri, passwor);
            System.out.println("Koneksi berhasil");

        } catch (SQLException ex) {
            System.out.println("Masih belum koneksi");
        }
        return con;
    }

    public void close() {
        try {
            conn.close();
        } catch (SQLException ex) {
            System.out.println("Tidak bisa tutup koneksi");
        }
    }

    public static void main(String[] args) {
        connection k = new connection();
        k.getDBConnection();
    }
}
